# -*- coding: utf-8 -*-
import smtplib
from email.mime.text import MIMEText
from email.header import Header


smtp_server='smtp.qq.com' # 要发送的服务器
port=465 # 服务器端口号
#sender = '353131760@qq.com'  # 发送邮箱的账号
sender = '2992849512@qq.com'  # 发送邮箱的账号
#sender_password='oazpgdzgbppobidg'  # 发送邮箱的授权码,我自已的
sender_password='fbporjsdjvjrdeag'  # 发送邮箱的授权码
#receivers = ['353131760@qq.com']
receivers = ['notice-retraction@amazon.co.uk']  # 接收邮件，可设置为你的QQ邮箱或者其他邮箱

messages = """From:<fuzhouwuqixin@sina.com>
To: <notice-retraction@amazon.co.uk>
Subject: Retract the Complaint ID: 6590306862

Dear Amazon，

I am Edward Goodwin, design right owner of  number: 002211268-0006. I have talked with the seller and agreed with them to sell this product on amazon.
We request for retracting the complaint. 
Seller ID:  A2FSFHVS5IV2U5 
--Complaint ID: 6590306862
-- ASIN impacted:  B0817PR1R1
Please help to reinstate the ASIN: B0817PR1R1 as soon as possible.
Thank you very much.

Best regards,
Edward Goodwin
"""

try:
    smtpObj = smtplib.SMTP_SSL(smtp_server, port)  #将smtplib.SMTP()改成smtplib.SMTP_SSL()
    smtpObj.set_debuglevel(1)
    smtpObj.login(sender, sender_password)
    #smtpObj.sendmail(sender, receivers, message.as_string())
    smtpObj.sendmail(sender, receivers, messages.encode("utf-8"))
    print("邮件发送成功")
    smtpObj.quit()
except smtplib.SMTPException as e:
    print("Error: 无法发送邮件{}".format(e))